<?php
class combo_model extends MY_Model {
	var $model = 'combo';
	
	function SampleReference()
	{
		$ls_sql	= "	SELECT	ref_key value,
							ref_name display
					FROM	sample_reference 
					ORDER BY ref_key";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	function ITApplication()
	{
		$ls_sql	= "	SELECT	APP_ID value,
							APP_NAME display
					FROM	IT_APPLICATION
					ORDER BY APP_NAME";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function EXTKondisi()
	{
		$ls_sql	= "	SELECT	KODE_KONDISI value,
							NAMA_KONDISI display
					FROM	EXT_KONDISI
					ORDER BY NAMA_KONDISI";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}
	
	function EXTVendor()
	{
		$ls_sql	= "	SELECT	KODE_VENDOR value,
							NAMA_VENDOR display
					FROM	EXT_VENDOR
					ORDER BY NAMA_VENDOR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function ISPCustomer()
	{
		$ls_sql	= "	SELECT	KODE_CUSTOMER value,
							NAMA display
					FROM	ISP_CUSTOMER
					ORDER BY NAMA";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function ISPProduk()
	{
		$ls_sql	= "	SELECT	KODE_PRODUK value,
							NAMA_PRODUK display
					FROM	ISP_PRODUK
					ORDER BY NAMA_PRODUK";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function ISPVendor()
	{
		$ls_sql	= "	SELECT	KODE_VENDOR value,
							NAMA_VENDOR display
					FROM	EXT_VENDOR WHERE APP_ID='ISP'
					ORDER BY NAMA_VENDOR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}
						
	function SWRole($as_app_id='')
	{
		$ls_sql	= "	SELECT	role_id value,
							role_name display
					FROM	it_role
					WHERE	1 = 1
							".($as_app_id=='' ? '' : "AND app_id='".$as_app_id."'")."
					ORDER BY role_name";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}
	
	function SWRegional()
	{
		$ls_sql	= "	SELECT	regional_code value,
							regional_name display
					FROM	sw_regional
					ORDER BY display";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	function SWCountry()
	{
		$ls_sql	= "	SELECT	country_code value,
							country_name display
					FROM	sw_country
					WHERE status = 'Y' 
					ORDER BY display";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	function SWCountryAll()
	{
		$ls_sql	= "	SELECT	country_code value,
							country_name display
					FROM	sw_country 
					ORDER BY display";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	function SWProvince()
	{
		$ls_sql	= "	SELECT	province_code value,
							province_name display
					FROM	sw_province
					ORDER BY display";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	function SWCity($as_province_code = '')
	{
		if($as_province_code != '') {
			$ls_sql	= "	SELECT	city_code value,
								city_name display 
						FROM	sw_city 
						WHERE	province_code = '".$as_province_code."'"." 
						ORDER BY display";
		}else{
			$ls_sql	= "	SELECT	city_code value,
								city_name display 
						FROM	sw_city 
						ORDER BY display";
		}	

		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
}
?>